<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>24.集合实践</title>
</head>
<body>
<script>
  let arr1 = [1,2,3,4,5,6,1,2,8]
  let arr2 = [2,3,4,5,6,6,99]

  //交集
  let arr1_new = [...new Set(arr1)]
  let jiao = arr1_new.filter(item=> new Set(arr2).has(item))
  console.log(jiao)

  //并集
  let bing =  [...new Set([...arr1,...arr2])]
  console.log(bing)
  
  //差集
  let cha = [...new Set(arr1)].filter(item=> !new Set(arr2).has(item))
  console.log(cha)
</script>
</body>
</html>